<html>
<head><meta charset="utf-8"><title>Definition of volatile semantics · t-lang/wg-unsafe-code-guidelines · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/index.html">t-lang/wg-unsafe-code-guidelines</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Definition.20of.20volatile.20semantics.html">Definition of volatile semantics</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="171881266"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Definition%20of%20volatile%20semantics/near/171881266" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Definition.20of.20volatile.20semantics.html#171881266">(Jul 28 2019 at 09:00)</a>:</h4>
<p>@comex and me are having an interesting discussion at <a href="https://www.reddit.com/r/rust/comments/chmnuo/any_unsafe_way_to_get_read_access_to/euyuea4/" target="_blank" title="https://www.reddit.com/r/rust/comments/chmnuo/any_unsafe_way_to_get_read_access_to/euyuea4/">https://www.reddit.com/r/rust/comments/chmnuo/any_unsafe_way_to_get_read_access_to/euyuea4/</a></p>



<a name="171881271"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Definition%20of%20volatile%20semantics/near/171881271" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Definition.20of.20volatile.20semantics.html#171881271">(Jul 28 2019 at 09:00)</a>:</h4>
<p>I feel we should put the result of this somewhere into the UCG -- a new issue, at least</p>



<a name="171940955"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Definition%20of%20volatile%20semantics/near/171940955" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Definition.20of.20volatile.20semantics.html#171940955">(Jul 29 2019 at 12:29)</a>:</h4>
<p>I added a note at <a href="https://github.com/rust-lang/unsafe-code-guidelines/issues/33#issuecomment-515969457" target="_blank" title="https://github.com/rust-lang/unsafe-code-guidelines/issues/33#issuecomment-515969457">https://github.com/rust-lang/unsafe-code-guidelines/issues/33#issuecomment-515969457</a> because I didn't feel like opening a third issue around volatile would help (we have one for MMIO and one for interaction with concurrency, which I think covers the two things volatile is used for, and they are already mixed up, of course).<br>
The problem is, these threads are both very long, nobody is going to read them entirely. But it's also not like they have reached a firm conclusion or even agreed on a clear core with some open questions. it's just all-around messy and in flux. I am not sure what to do about that.</p>



<a name="171941160"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Definition%20of%20volatile%20semantics/near/171941160" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Definition.20of.20volatile.20semantics.html#171941160">(Jul 29 2019 at 12:32)</a>:</h4>
<p><span class="user-mention" data-user-id="120791">@RalfJ</span> could we use that for <code>black_box</code> ? E.g. saying that <code>black_box</code> is an externally observable event, and then have each backend say what it does in the actual hardware (e.g. nothing)</p>



<a name="171941620"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Definition%20of%20volatile%20semantics/near/171941620" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Definition.20of.20volatile.20semantics.html#171941620">(Jul 29 2019 at 12:39)</a>:</h4>
<p><span class="user-mention" data-user-id="132920">@gnzlbg</span> I wondered the same thing, but didn't ponder it yet</p>



<a name="171941738"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Definition%20of%20volatile%20semantics/near/171941738" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Definition.20of.20volatile.20semantics.html#171941738">(Jul 29 2019 at 12:40)</a>:</h4>
<p>or maybe worded differently, if we can't say that for <code>black_box</code>, why can we say that for volatile ?</p>



<a name="171943577"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Definition%20of%20volatile%20semantics/near/171943577" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Definition.20of.20volatile.20semantics.html#171943577">(Jul 29 2019 at 13:08)</a>:</h4>
<p>indeed that would be the question</p>



<a name="171943604"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Definition%20of%20volatile%20semantics/near/171943604" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Definition.20of.20volatile.20semantics.html#171943604">(Jul 29 2019 at 13:09)</a>:</h4>
<p>I added another post trying to explain what I mean with the first post by means of an example... but this is much harder to explain whan I initially realized^^</p>



<a name="171943620"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Definition%20of%20volatile%20semantics/near/171943620" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Definition.20of.20volatile.20semantics.html#171943620">(Jul 29 2019 at 13:09)</a>:</h4>
<p>really this is material for several blog posts that I don't have time to write right now, so all I can offer is this braindump</p>



<a name="171943716"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Definition%20of%20volatile%20semantics/near/171943716" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Definition.20of.20volatile.20semantics.html#171943716">(Jul 29 2019 at 13:10)</a>:</h4>
<p>Now I just have to remember to link to <a href="https://github.com/rust-lang/unsafe-code-guidelines/issues/33#issuecomment-515969457" target="_blank" title="https://github.com/rust-lang/unsafe-code-guidelines/issues/33#issuecomment-515969457">https://github.com/rust-lang/unsafe-code-guidelines/issues/33#issuecomment-515969457</a> any time volatile comes up, because being burried somewhere in that long thread, nobody is going to be able to find this^^</p>



<a name="171947542"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Definition%20of%20volatile%20semantics/near/171947542" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Definition.20of.20volatile.20semantics.html#171947542">(Jul 29 2019 at 13:59)</a>:</h4>
<p>My opinion, but I think it's fine to edit the initial comment with a table of contents to important comments / other PRs</p>



<a name="171948230"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Definition%20of%20volatile%20semantics/near/171948230" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Definition.20of.20volatile.20semantics.html#171948230">(Jul 29 2019 at 14:06)</a>:</h4>
<p>yeah I considered that as well. but I am also very biased about what the important comments are. ;)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>